import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import routes from "./router";
import iView from "iview";
import Util from "@/assets/js/Util";
Vue.use(VueRouter)

const router = new VueRouter({
  routes
})

router.beforeEach((to, from, next) => {
  iView.LoadingBar.start();
  Util.title(to.meta.title);
  console.log("to",to)
  if(to.fullPath=="/login" || to.fullPath=="/register"){
    next()
  } else {
    if(sessionStorage.getItem('AccessToken')){
      next()
    } else {
      next("/login")
    }
  }
})
// router
router.afterEach((to) => {
  iView.LoadingBar.finish();
});



export default router
